<?php

/**
 * BachkimArtice form base class.
 *
 * @method BachkimArtice getObject() Returns the current form's model object
 *
 * @package    jobeet
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBachkimArticeForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'category_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimCategory'), 'add_empty' => false)),
      'title'           => new sfWidgetFormInputText(),
      'content_summary' => new sfWidgetFormTextarea(),
      'content_detail'  => new sfWidgetFormTextarea(),
      'author'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimUser'), 'add_empty' => false)),
      'images'          => new sfWidgetFormInputText(),
      'download_link'   => new sfWidgetFormInputText(),
      'number_read'     => new sfWidgetFormInputText(),
      'is_public'       => new sfWidgetFormInputCheckbox(),
      'is_activated'    => new sfWidgetFormInputCheckbox(),
      'language_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimLanguage'), 'add_empty' => false)),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'category_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimCategory'))),
      'title'           => new sfValidatorString(array('max_length' => 255)),
      'content_summary' => new sfValidatorString(array('required' => false)),
      'content_detail'  => new sfValidatorString(array('required' => false)),
      'author'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimUser'))),
      'images'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'download_link'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'number_read'     => new sfValidatorInteger(array('required' => false)),
      'is_public'       => new sfValidatorBoolean(array('required' => false)),
      'is_activated'    => new sfValidatorBoolean(array('required' => false)),
      'language_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BachkimLanguage'))),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'BachkimArtice', 'column' => array('title')))
    );

    $this->widgetSchema->setNameFormat('bachkim_artice[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'BachkimArtice';
  }

}
